<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>IE缓存问题</title>

    <style>
        #div {
            width: 200px;
            height: 100px;
            border: solid 5px aquamarine;
        }
    </style>
</head>

<body>
    <button id="btn">IE缓存</button>
    <div id="div"></div>

    <script>
        const btn = document.querySelector('#btn');
        const div = document.querySelector('#div');

        btn.addEventListener('click', function() {
            const xhr = new XMLHttpRequest();
            // ie浏览器缓存问题，解决办法在连接后面拼接时间戳，这样每次都是新的一个请求，就不会有缓存问题
            xhr.open('get', 'http://127.0.0.1:9999/ie?t=' + Date.now());
            xhr.send();
            xhr.onreadystatechange = function() {
                if (xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 300) {
                    div.innerHTML = xhr.response;
                }
            }
        })
    </script>
</body>

</html>